#pragma once

#include "common.h"

#include "RenderUtils.h"

struct _RenderInitData;

class D3DRender
{
public:
	D3DRender(void);
	~D3DRender(void);

	void Update();
	void Draw();

	void ReleaseResizedResources();
	void OnResize();

	void GetDXGISwapChainPtr(IDXGISwapChain ** ptr) const;
	void GetID3D10DevicePtr(ID3D10Device1 ** ptr ) const;
	void GetIDXGIDevicePtr(IDXGIDevice ** ptr ) const;

private:
	void Init();

	IDXGISwapChain * swapChain;
	IDXGIDevice * dxgiDevice;
	ID3D10Device1 * device;
	ID3D10RenderTargetView * renderTargetView;
	ID3D10Texture2D * depthStencilBuffer;
	ID3D10DepthStencilView * depthStencilView;

	D3DXMATRIX projectionMatrix;
};

inline void D3DRender::GetDXGISwapChainPtr(IDXGISwapChain ** ptr) const
{
	HR(swapChain->QueryInterface(__uuidof(IDXGISwapChain), reinterpret_cast<void**>(ptr)));
}

inline void D3DRender::GetID3D10DevicePtr(ID3D10Device1 ** ptr ) const
{
	HR(device->QueryInterface(__uuidof(ID3D10Device1), reinterpret_cast<void**>(ptr)));
}

inline void D3DRender::GetIDXGIDevicePtr(IDXGIDevice ** ptr ) const
{
	HR(device->QueryInterface(__uuidof(IDXGIDevice), reinterpret_cast<void**>(ptr)));
}
